package com.situ.mymall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.mymall.mapper.PayInfoMapper;
import com.situ.mymall.pojo.entity.PayInfo;
import com.situ.mymall.pojo.query.PayInfoQuery;
import com.situ.mymall.service.IPayInfoService;
import com.situ.mymall.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PayInfoServiceImpl implements IPayInfoService {

    @Autowired
    private PayInfoMapper payInfoMapper;


    @Override
    public PageResult list(PayInfoQuery payInfoQuery) {
        PageHelper.startPage(payInfoQuery.getPage(), payInfoQuery.getLimit());
        List<PayInfo> list = payInfoMapper.list(payInfoQuery);
        PageInfo pageInfo = new PageInfo(list);
        int totalCount = (int) pageInfo.getTotal();

        return PageResult.ok(totalCount,list);
    }

    @Override
    public PayInfo selectById(Integer id) {
        return payInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public void add(PayInfo payInfo) {
        payInfoMapper.insertSelective(payInfo);
    }

    @Override
    public void deleteById(Integer id) {
        payInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void deleteAll(Integer[] ids) {
        payInfoMapper.deleteAll(ids);
    }

    @Override
    public void update(PayInfo payInfo) {
        payInfoMapper.updateByPrimaryKeySelective(payInfo);
    }
}
